﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Experimental.Playables.MaterialEffectPlayable
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using System.Runtime.CompilerServices;
using UnityEngine.Bindings;
using UnityEngine.Playables;
using UnityEngine.Scripting;

#nullable disable
namespace UnityEngine.Experimental.Playables
{
  /// <summary>
  ///   <para>An implementation of IPlayable that allows application of a Material shader to one or many texture inputs to produce a texture output.</para>
  /// </summary>
  [NativeHeader("Runtime/Shaders/Director/MaterialEffectPlayable.h")]
  [NativeHeader("Runtime/Director/Core/HPlayable.h")]
  [StaticAccessor("MaterialEffectPlayableBindings", StaticAccessorType.DoubleColon)]
  [RequiredByNativeCode]
  [NativeHeader("Runtime/Export/Director/MaterialEffectPlayable.bindings.h")]
  public struct MaterialEffectPlayable : IPlayable, IEquatable<MaterialEffectPlayable>
  {
    private PlayableHandle m_Handle;

    public static MaterialEffectPlayable Create(PlayableGraph graph, Material material, int pass = -1)
    {
      return new MaterialEffectPlayable(MaterialEffectPlayable.CreateHandle(graph, material, pass));
    }

    private static PlayableHandle CreateHandle(PlayableGraph graph, Material material, int pass)
    {
      PlayableHandle handle = PlayableHandle.Null;
      return !MaterialEffectPlayable.InternalCreateMaterialEffectPlayable(ref graph, material, pass, ref handle) ? PlayableHandle.Null : handle;
    }

    internal MaterialEffectPlayable(PlayableHandle handle)
    {
      this.m_Handle = !handle.IsValid() || handle.IsPlayableOfType<MaterialEffectPlayable>() ? handle : throw new InvalidCastException("Can't set handle: the playable is not an MaterialEffectPlayable.");
    }

    public PlayableHandle GetHandle() => this.m_Handle;

    public static implicit operator Playable(MaterialEffectPlayable playable)
    {
      return new Playable(playable.GetHandle());
    }

    public static explicit operator MaterialEffectPlayable(Playable playable)
    {
      return new MaterialEffectPlayable(playable.GetHandle());
    }

    public bool Equals(MaterialEffectPlayable other) => this.GetHandle() == other.GetHandle();

    public Material GetMaterial() => MaterialEffectPlayable.GetMaterialInternal(ref this.m_Handle);

    public void SetMaterial(Material value)
    {
      MaterialEffectPlayable.SetMaterialInternal(ref this.m_Handle, value);
    }

    public int GetPass() => MaterialEffectPlayable.GetPassInternal(ref this.m_Handle);

    public void SetPass(int value)
    {
      MaterialEffectPlayable.SetPassInternal(ref this.m_Handle, value);
    }

    [NativeThrows]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern Material GetMaterialInternal(ref PlayableHandle hdl);

    [NativeThrows]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetMaterialInternal(ref PlayableHandle hdl, Material material);

    [NativeThrows]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern int GetPassInternal(ref PlayableHandle hdl);

    [NativeThrows]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SetPassInternal(ref PlayableHandle hdl, int pass);

    [NativeThrows]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool InternalCreateMaterialEffectPlayable(
      ref PlayableGraph graph,
      Material material,
      int pass,
      ref PlayableHandle handle);

    [NativeThrows]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool ValidateType(ref PlayableHandle hdl);
  }
}
